﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Xml;
using OgilvyOne.DALFactory;
using OgilvyOne.Utility;

namespace OgilvyOne.BLL
{
    /// <summary>
    /// 列表标签,循环替换标签内容
    /// <cms:labelsqllist value="标签定义名"></cms:labelsqllist>
    /// </summary>
    class LabelSqlListLabel : LabelCommonLabel
    {
        private SqlListLabel sl;

        public LabelSqlListLabel(CommonModel model)
            : base(model)
        {
            sl = new SqlListLabel(model);
        }


        public override string GetLabelLabelHtml()
        {
            sl.LabelStr = LabelStr;
            
            //sql / node
            XmlDocument doc = GetLabelValueXmlDocument(GetLabelValue());

            sl.LabelNodeStr = doc.SelectSingleNode("//list").Value;
            sl.Sqlstr = doc.SelectSingleNode("//sql").Value;
            /*if (doc.SelectSingleNode("//rows") != null)
            {
                sl.rows = int.Parse(doc.SelectSingleNode("//rows").Value);
            }*/
            //sl.MethodName = doc.SelectSingleNode("//method").Value;

            return sl.GetLabelHtml();
        }
    }
}
